package com.qyl.honghengshop.controller.customer;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qyl.honghengshop.dto.Comment;
import com.qyl.honghengshop.dto.Goods;
import com.qyl.honghengshop.service.CommentService;
import com.qyl.honghengshop.service.GoodsService;
import com.qyl.honghengshop.service.impl.CommentServiceImpl;
import com.qyl.honghengshop.service.impl.GoodsServiceImpl;
import com.qyl.honghengshop.utils.PageBean;

@Controller
@RequestMapping("/customer/goods")
public class PreGoodsController {

	private GoodsService goodsService = new GoodsServiceImpl();
	private CommentService commentService = new CommentServiceImpl();
	
	@RequestMapping("/goodsList")
	public String goodsList(Integer pageIndex,Integer pageSize,Goods goods,ModelMap map){
		
		int recordCount = goodsService.getRecordCount(goods);
		
		PageBean pageBean = new PageBean(pageIndex, recordCount, pageSize);
		
		pageBean.setPageSize(10);
		
		goodsService.shopTypeList(pageBean, goods);
		
		map.put("pageBean", pageBean);
		
		return "shop_list";
	}
	
	@RequestMapping("/goodsDetail")
	public String goodsDetail(Integer id,ModelMap map){
		
		Goods goods = goodsService.getShopById(id);
		
		List<Comment> commentList = commentService.getCommentList(id);
		
		map.put("commentList", commentList);
		
		map.put("goods", goods);
	
		return "pro_details";
		
	}
	
}
